﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLXuongCNTT.Object;
using QLXuongCNTT.ControlLayers;
namespace QLXuongCNTT
{
    public partial class frmPhong : Form
    {
        public frmPhong()
        {
            InitializeComponent();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
        ctrlPhong phong_ctr = new ctrlPhong();
        private void frmPhong_Load(object sender, EventArgs e)
        {
            dataGridView1.AutoGenerateColumns = false;
            bindingSource1.DataSource = phong_ctr.getPhong();
            bindingNavigator1.BindingSource = bindingSource1;
            dataGridView1.DataSource = bindingSource1;
           
        }

        private void toolStripbtnLuu_Click(object sender, EventArgs e)
        {
            bindingNavigatorPositionItem.Focus();
            if (phong_ctr.save() == true)
                MessageBox.Show(this, "Bạn đã lưu những thay đổi thành công!", "xác nhận", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

        }

        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            phong_ctr.Phong.Sophong = dataGridView1.CurrentRow.Cells[0].Value.ToString();
            phong_ctr.Phong.Loaiphong= dataGridView1.CurrentRow.Cells[1].Value.ToString();
            phong_ctr.AddPhong();
            bindingNavigator1.BindingSource.MoveLast();
        }
    }
}
